#include<iostream>
#include<ctime>
#include<unistd.h>
#include"blockQueue.hpp"
void* productor(void* arg)
{
    BlockQueue<int>* bq=static_cast<BlockQueue<int>*>(arg);
    while(true)
    {
        int data=rand()%10+1;
        bq->PushData(data);
        std::cout<<" productor data done:"<<data<<std::endl;
    }
    return nullptr;
}
void* consumer(void* arg)
{
    BlockQueue<int>* bq=static_cast<BlockQueue<int>*>(arg);
    while(true)
    {
        int data;
        bq->PopData(data);
        std::cout<<" consumer data done:"<<data<<std::endl;
    }
    return nullptr;
}
int main()
{
    srand((uint64_t)time(nullptr));
    BlockQueue<int>* bq=new  BlockQueue<int>(5);
    pthread_t c,p;
    pthread_create(&c,nullptr,productor,bq);
    pthread_create(&c,nullptr,consumer,bq);
    pthread_join(p,nullptr);
    pthread_join(c,nullptr);
    delete bq;
    return 0;
}